<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2018/12/28
 * Time: 18:31
 */

namespace common\sources\write\valueservice;


use common\models\craftsman\ValueService;
use Yii;

class ValueServiceAccess implements IValueServiceAccess {
    public function ModifyChatKeyWords($data) {
        $result = ValueService::findOne(['id' => $data['id']]);
        if ($result) {
            $result->chat_keys = $data['keywords'];
            if ($result->save()) {
                return true;
            }
        }
        return false;
    }

    public function ModifyCommentKeyWords($data) {
        $result = ValueService::findOne(['id' => $data['id']]);
        if ($result) {
            $result->praise = $data['comment'];
            if ($result->save()) {
                return true;
            }
        }
        return false;
    }

	//修改自定义关键字
	public function editCommentKeyWords($data) {
		$sql = 'UPDATE ' . ValueService::tableName() . ' SET praise_keys=:praise_keys WHERE id=:id ';
		return Yii::$app->db->createCommand($sql)
			->bindValues([
				':praise_keys' => $data['comment'],
				':id'          => $data['id']
			])->execute();
	}
}